package com.ysd.lis.controller.emr;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.dto.emr.EmrVersionTree;
import com.ysd.lis.entity.emr.EmrVersion;
import com.ysd.lis.request.emr.EmrVersionVo;
import com.ysd.lis.service.emr.EmrVersionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wh
 * @since 2025-06-04
 */
@RestController
@RequestMapping("/emr/version")
public class EmrVersionController extends BaseController {

    @Autowired
    private EmrVersionService emrVersionService;

    @ApiOperation("获取版本数据")
    @GetMapping("/getVersionList")
    public Result getVersionList() {
        List<EmrVersion> emrVersionList = emrVersionService.list(new LambdaQueryWrapper<EmrVersion>().eq(EmrVersion::getDelFlag, 0).orderByAsc(EmrVersion::getSeq));
        return Result.succ(1,"获取信息成功",emrVersionList);
    }

    @ApiOperation("获取版本和角色的树结构")
    @GetMapping("/getVersionRolesTree")
    public Result getVersionRolesTree() {
        return emrVersionService.getVersionRolesTree();
    }


    @ApiOperation("新增或编辑版本")
    @PostMapping("/saveOrEditVersion")
    public Result saveOrEditVersion(@RequestBody EmrVersionVo emrVersionVo) {
        return emrVersionService.saveOrEditVersion(emrVersionVo);
    }
    @ApiOperation("删除版本")
    @PostMapping("/deleteVersionDetail")
    public Result deleteVersionDetail(@RequestBody EmrVersionTree emrVersionTree) {
        return emrVersionService.deleteVersionDetail(emrVersionTree);
    }

    @ApiOperation("通过版本号获取对应等级下角色")
    @GetMapping("/getRolseItemByVersion")
    public Result getRolseItemByVersion(String versionCode) {
        return emrVersionService.getRolseItemByVersion(versionCode);
    }


}
